﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ViewModels="clr-namespace:Cineman.ViewModels"
    xmlns:adduplex="clr-namespace:AdDuplex;assembly=AdDuplex.WindowsPhone"
    x:Class="Cineman.MainPage"
    mc:Ignorable="d"
    d:DataContext="{d:DesignData SampleData/SampleData.xaml}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <phone:PhoneApplicationPage.Resources>

        <DataTemplate x:Key="MoviesDataTemplate">
            <Grid Margin="12,7,0,5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Image Source="{Binding PosterLocal}" Width="99" Height="136" Grid.Column="0" Stretch="UniformToFill"/>
                <StackPanel Margin="0,0,0,0" Grid.Column="1">
                    <TextBlock Text="{Binding Title}" TextWrapping="NoWrap" Margin="12,0,0,0" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                    <TextBlock TextWrapping="Wrap" Margin="12,0,0,0" Style="{StaticResource PhoneTextAccentStyle}">
                        <Run Text="{Binding LocalizedResources.AirDateText, Source={StaticResource LocalizedStrings}}"/>
                        <Run Text="{Binding AirDate, StringFormat=\{0:M\} }" ></Run>
                    </TextBlock>
                    <TextBlock Text="{Binding AirTimeText}" TextWrapping="Wrap" Margin="12,0,0,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
                    <ProgressBar IsIndeterminate="True" Visibility="{Binding IsDetailsLoaded}" Margin="0,12"></ProgressBar>
                </StackPanel>
            </Grid>
        </DataTemplate>

    </phone:PhoneApplicationPage.Resources>

    <phone:PhoneApplicationPage.FontFamily>
        <StaticResource ResourceKey="PhoneFontFamilyNormal"/>
    </phone:PhoneApplicationPage.FontFamily>
    <phone:PhoneApplicationPage.FontSize>
        <StaticResource ResourceKey="PhoneFontSizeNormal"/>
    </phone:PhoneApplicationPage.FontSize>
    <phone:PhoneApplicationPage.Foreground>
        <StaticResource ResourceKey="PhoneForegroundBrush"/>
    </phone:PhoneApplicationPage.Foreground>
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">

        <!--Pivot Control-->
        <TextBlock 
                x:Name="NoPhotosFound"
                Visibility="Collapsed" 
                Style="{StaticResource PhoneTextTitle2Style}">
				<Run Text="Could not get data :("/>
        </TextBlock>
        <phone:Pivot
            Title="{Binding LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Margin="0,0,0,80">
            <!--Pivot item one-->
            <phone:PivotItem Header="{Binding LocalizedResources.TodayPivotTitle, Source={StaticResource LocalizedStrings}}">
                <phone:LongListSelector x:Name="TodayList"
                    Margin="0,0,-12,0" 
					ItemsSource="{Binding Today.Items}"
					ItemTemplate="{StaticResource MoviesDataTemplate}" 
                    SelectionChanged="TodayListSelector_SelectionChanged" LayoutMode="List"/>
            </phone:PivotItem>

            <!--Pivot item two-->
            <phone:PivotItem Header="{Binding LocalizedResources.ComingSoonPivotTitle, Source={StaticResource LocalizedStrings}}">
                <phone:LongListSelector x:Name="ComingList"
                    Margin="0,0,-12,0" 
					ItemsSource="{Binding ComingSoon.Items}"
					ItemTemplate="{StaticResource MoviesDataTemplate}" SelectionChanged="ComingList_SelectionChanged"/>
            </phone:PivotItem>
        </phone:Pivot>
        <adduplex:AdControl x:Name="adDuplexAd" AppId="89179" Canvas.ZIndex="999" VerticalAlignment="Bottom"/>
        <StackPanel VerticalAlignment="Center" x:Name="Overlay" Visibility="Collapsed">
            <TextBlock HorizontalAlignment="Center">
					<Run Text="{Binding LocalizedResources.LoadingText, Source={StaticResource LocalizedStrings}}"/>
            </TextBlock>
            <ProgressBar x:Name="OverlayProgressBar" IsIndeterminate="True" />
        </StackPanel>
        <StackPanel VerticalAlignment="Center" Name="OverlayError" Visibility="Collapsed">
            <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap">
					<Run x:Name="ErrorMessage" />
            </TextBlock>
        </StackPanel>
        <!--Uncomment to see an alignment grid to help ensure your controls are
            aligned on common boundaries.  The image has a top margin of -32px to
            account for the System Tray. Set this to 0 (or remove the margin altogether)
            if the System Tray is hidden.

            Before shipping remove this XAML and the image itself.-->
        <!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" IsHitTestVisible="False" />-->
    </Grid>

</phone:PhoneApplicationPage>